package cn.chinaunicom.sdsi.gacx.commonSvc.controller;

import cn.chinaunicom.sdsi.frm.base.BaseController;
import cn.chinaunicom.sdsi.gacx.author.service.AuthorService;
import cn.chinaunicom.sdsi.gacx.commonSvc.service.ICommonSvcService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.json.JSONObject;

/**
 * @author chenxl add by 2018-2-5 09:37:52
 * 
 *         通用服务调用
 *
 */

@Controller
@RequestMapping("/commonSvc")
public class CommonSvcController extends BaseController {

	private final Log log = LogFactory.getLog(CommonSvcController.class);

	@Autowired
	private ICommonSvcService commonSvcService;

	@RequestMapping(value = "/doCommonSvc")
	@ResponseBody
	public String doCommonSvc(@RequestBody HashMap<String, Object> map) {
		// 提供服务列表
		String methodStr = "getTelNoByImsi,getImsiByTelNo";
		JSONObject obj = new JSONObject();

		String method = map.get("method") == null ? "" : (String) map.get("method");
		if (method.equals("")) {
			obj.put("code", "9999");
			obj.put("msg", "调用接口失败：请求参数【method】不能为空,请核实处理！");
			return obj.toString();
		} else if (methodStr.indexOf(method) == -1) {
			obj.put("code", "9999");
			obj.put("msg", "调用接口失败：未查询到接口【" + method + "】,请联系管理员！");
			return obj.toString();
		}

		return commonSvcService.doCommonSvcService(map);
	}
}